// components/mc-goods-item/mc-goods-item.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      type: Object,
      value: {}
    },
    counter: Number
  },

  /**
   * 组件的初始数据
   */
  data: {
    counter: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    addClick(ev) {
      if (this.data.counter < 20) {
        this.setData({
          counter: this.data.counter + 1
        })

        const count = this.data.counter
        const price = this.properties.item.minPrice
        console.log("xxxxxx", count)
        console.log("xxxxxx", price)
        //数据继续往外层传递
        this.triggerEvent('addClick', {
          count,
          price
        }, {})
      }
    },
    desClick(ev) {
      if (this.data.counter > 0) {
        this.setData({
          counter: this.data.counter - 1
        })

        const count = this.data.counter
        const price = this.properties.item.minPrice
        //数据继续往外层传递
        this.triggerEvent('desClick', {
          count,
          price
        }, {})
      }
    }
  }
})